home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / DJINC106.ARJ / SMPLHIST.H < prev    next >
C/C++ Source or Header  |  1992-03-29  |  2KB  |  73 lines

  1. // This may look like C code, but it is really -*- C++ -*-
  2. /* 
  3. Copyright (C) 1988 Free Software Foundation
  4.     written by Dirk Grunwald (grunwald@cs.uiuc.edu)
  5.  
  6. This file is part of the GNU C++ Library.  This library is free
  7. software; you can redistribute it and/or modify it under the terms of
  8. the GNU Library General Public License as published by the Free
  9. Software Foundation; either version 2 of the License, or (at your
  10. option) any later version.  This library is distributed in the hope
  11. that it will be useful, but WITHOUT ANY WARRANTY; without even the
  12. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  13. PURPOSE.  See the GNU Library General Public License for more details.
  14. You should have received a copy of the GNU Library General Public
  15. License along with this library; if not, write to the Free Software
  16. Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  17. */
  18.  
  19. #ifndef SampleHistogram_h
  20. #ifdef __GNUG__
  21. #pragma interface
  22. #endif
  23. #define SampleHistogram_h 1
  24.  
  25. #include <stream.h>
  26. #include <SmplStat.h>
  27.  
  28. extern const int SampleHistogramMinimum;
  29. extern const int SampleHistogramMaximum;
  30.  
  31. class SampleHistogram : public SampleStatistic 
  32. {
  33. protected:
  34.     short howManyBuckets;
  35.     int *bucketCount;
  36.     double *bucketLimit;
  37.  
  38. public:
  39.     
  40.     SampleHistogram(double low, double hi, double bucketWidth = -1.0);
  41.  
  42.     ~SampleHistogram();
  43.  
  44.     virtual void reset();
  45.     virtual void operator+=(double);
  46.  
  47.     int similarSamples(double);
  48.  
  49.     int buckets();
  50.  
  51.     double bucketThreshold(int i);
  52.     int inBucket(int i);
  53.     void printBuckets(ostream&);
  54.  
  55. };
  56.  
  57.  
  58. inline int SampleHistogram:: buckets() { return(howManyBuckets); };
  59.  
  60. inline double SampleHistogram:: bucketThreshold(int i) {
  61.     if (i < 0 || i >= howManyBuckets)
  62.         error("invalid bucket access");
  63.     return(bucketLimit[i]);
  64. }
  65.  
  66. inline int SampleHistogram:: inBucket(int i) {
  67.     if (i < 0 || i >= howManyBuckets)
  68.         error("invalid bucket access");
  69.     return(bucketCount[i]);
  70. }
  71.  
  72. #endif
  73.